#include "DoxyDescription.h"

DoxyDescription::DoxyDescription()
{
}

DoxyDescription::~DoxyDescription()
{
}


void DoxyDescription::loadConfig(const QDomElement& element)
{
    qDebug() << element.tagName();
    QDomNodeList list = element.childNodes();

    for(int i =0; i <list.size(); i++)
    {
        if(!list.at(i).isNull())
        {
            if(list.at(i).isElement())
            {
                QDomElement subElement = list.at(i).toElement();

                //check if the element is a paragraph tag
                if(subElement.tagName() == "para")
                {
                    //get the text
                    m_text = subElement.text();
                    loadRefrences(subElement);
                }

            }
        }
    }

}

QString DoxyDescription::getText() const
{
    return m_text;
}

void DoxyDescription::loadRefrences(const QDomElement &element)
{
    QDomNodeList list = element.childNodes();
    for(int i = 0; i < list.size(); i++)
    {
        if(!list.at(i).isNull())
        {
            if(list.at(i).isElement())
            {
                QDomElement subElement = list.at(i).toElement();
                if(subElement.tagName() == "ref")
                {
                    if(subElement.attribute("kindref") == "compound")
                    {
                        RefItem refrence;
                        refrence.refId = subElement.attribute("refid");
                        refrence.name = subElement.text();
                        m_refrences.push_back(refrence);
                    }
                }
            }
        }
    }
}
